﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Controls;
using MyFloridaHouse.ServiceConn.DistrBldrSvcRef;

namespace MyFloridaHouse.libSvOpenDistricts.Dialogs
{
    public class FileListDlg: _BaseDlg
    {

        private FileListDlgView dlgWindow = new FileListDlgView();

        public FileListDlg(PropertyChangedEventHandler propertyChangedEventHandler, StackPanel childWindowStackPanel)
        {
            InitializeDlgWindow(propertyChangedEventHandler, childWindowStackPanel, dlgWindow);
        }

        #region form data properties


        private string _title = "File List";
        public string title
        {
            get { return _title; }
            set
            {
                if (_title != value)
                {
                    _title = value;
                    NotifyPropertyChanged("title");
                }
            }
        }

        private ObservableCollection<FileInfoDTO> _fileNameList = new ObservableCollection<FileInfoDTO>();
        public ObservableCollection<FileInfoDTO> fileNameList
        {
            get { return _fileNameList; }
            set
            {
                _fileNameList = value;
                NotifyPropertyChanged("fileNameList");
            }
        }

        private int _fileNameListSelectedIndex = -1;
        public int fileNameListSelectedIndex
        {
            get { return _fileNameListSelectedIndex; }
            set
            {
                if (_fileNameListSelectedIndex != value)
                {
                    _fileNameListSelectedIndex = value;
                    if ((_fileNameListSelectedIndex < 0) | (_fileNameListSelectedIndex > _fileNameList.Count - 1))
                    {
                        selectedFileName = "";
                    }
                    else
                    {
                        selectedFileName = _fileNameList[fileNameListSelectedIndex].fileName;
                    }
                    NotifyPropertyChanged("fileOpenFileNameListSelectedIndex");
                }
            }
        }

        private string _selectedFileName = "";
        public string selectedFileName
        {
            get { return _selectedFileName; }
            set
            {
                if (_selectedFileName != value)
                {
                    _selectedFileName = value;
                    NotifyPropertyChanged("selectedFileName");
                }
            }
        }

        public FileInfoDTO selectedFileInfo
        {
            get
            {
                return fileNameList[fileNameListSelectedIndex];
            }
        }

#endregion

        public virtual bool CmdOKCanExecute(object parameter)
        {
            return true;
        }
    }
}
